<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="com.DBtools" %>
    <%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="../bootstrap.jsp"%>
<style>
.AddForm{
padding:40px;
}
</style>
<!-- 
                   可能需要使用的标签
					<small id="PassWordHelp" class="form-text text-muted">
						学院账号的默认密码为”123456“</small>
 -->
<meta charset="UTF-8">
<title>新增学院账号</title>
</head>
<body>
<%
//接受返回的页码
String pg=request.getParameter("pg");
//接收的学院账号、名称的情况
String DepNumFB=(String)request.getAttribute("DepNumFB");
String DepNameFB=(String)request.getAttribute("DepNameFB");
//接收填写表单前的数据
String DepNum=(String)request.getAttribute("DepNum");
String DepName=(String)request.getAttribute("DepName");
String DepConName=(String)request.getAttribute("DepConName");
String DepConEmail1=(String)request.getAttribute("DepConEmail1");
String DepConEmail2=(String)request.getAttribute("DepConEmail2");
String submitFB=(String)request.getAttribute("submitFB");
session.setAttribute("pagenumber",pg);//放进session，servlet调用
%>
	<div class="AddForm">
	<h4 style="font-weight: bolder; left: 20px">添加学院账号</h4>
		<!-- 这里是表单 -->
		<form action="AddDepNum">
			<div class="form-row">
				<div class="form-group col-md-6">
						<%if(DepNumFB=="不存在账号"){
							%>
					    <label for="InputDepNum">学院账号</label>
					    <div class="input-group isinvalid">
						<div class="input-group-prepend">
							<span class="input-group-text" id="addon-wrapping">106512</span>
						</div>
						<input type="number" class="form-control" name="DepNum"
							id="InputDepNum" placeholder="两位数字"
							aria-describedby="addon-wrapping"
							oninput="value=value.slice(0,2)"
							value=<%=DepNum.substring(6,DepNum.length())%> required>
						</div>
						<%}else if(DepNumFB=="存在账号"){%>
						<label for="InputDepNum">学院账号</label>
					    <div class="input-group isinvalid">
						<div class="input-group-prepend">
							<span class="input-group-text" id="addon-wrapping">106512</span>
						</div>
						<input type="number" class="form-control is-invalid" name="DepNum"
							id="InputDepNum" placeholder="两位数字"
							aria-describedby="addon-wrapping"
							oninput="value=value.slice(0,2)"
							value=<%=DepNum.substring(6,DepNum.length())%> required>
						<div class="invalid-feedback">该账号已被使用</div>
						</div>
						<%}else if(DepNumFB==null){ %>
						<!-- 为空正常显示标签 -->
						<label for="InputDepNum">学院账号</label>
					    <div class="input-group">
						<div class="input-group-prepend">
							<span class="input-group-text" id="addon-wrapping">106512</span>
						</div>
						<input type="number" class="form-control" name="DepNum"
							id="InputDepNum" placeholder="两位数字"
							aria-describedby="addon-wrapping"
							oninput="value=value.slice(0,2)" required>
						</div>
						<%} %>
				</div>
				<div class="form-group col-md-6">
					<label for="InputPwd">密码</label> 
					<input type="text" name="Pwd"
						class="form-control" id="InputPwd" value="123456" readonly> 
				</div>
			</div>
			<div class="form-group">
				<%
				if (DepNameFB == "不存在学院") {
				%>
				<label for="InputDepName">学院名称</label> 
				<input type="text"
					name="DepName" class="form-control" id="InputDepName"
					placeholder="如：金融学院/中国经济研究院" 
					value=<%=DepName %> required>
				<%
				}else if (DepNameFB == "存在学院") {
				%>
				<label for="InputDepName">学院名称</label> 
				<input type="text"
					name="DepName" class="form-control is-invalid" id="InputDepName"
					placeholder="如：金融学院/中国经济研究院" 
					value=<%=DepName %> required>
				<div class="invalid-feedback">该学院已有账号</div>
				<%}else if(DepNumFB==null){ %>
				<!-- 为空正常显示标签 -->
				<label for="InputDepName">学院名称</label> 
				<input type="text"
					name="DepName" class="form-control" id="InputDepName"
					placeholder="如：金融学院/中国经济研究院"  required>
				<%} %>
			</div>
			<div class="form-row">
				<div class="form-group col-md-6">
					<%
					if (submitFB == null) {
					%>
					<label for="InputDepConName">学院联系人姓名</label> <input type="text"
						placeholder="如：王雨华" name="DepConName" class="form-control"
						id="InputDepConName" required>
					<%
					} else if (submitFB == "提交失败") {
					%>
					<label for="InputDepConName">学院联系人姓名</label> <input type="text"
						placeholder="如：王雨华" name="DepConName" value=<%=DepConName%>
						class="form-control" id="InputDepConName" required>
					<%
					}
					%>
				</div>
				<div class="form-group col-md-4">
					<%
					if (submitFB == null) {
					%>
					<label for="InputDepConEmail1">邮箱账号</label> <input type="text"
						placeholder="如：610197812" name="DepConEmail1" class="form-control"
						id="InputDepConEmail1" required>
					<%
					} else if (submitFB == "提交失败") {
					%>
					<label for="InputDepConEmail1">邮箱账号</label> <input type="text"
						placeholder="如：610197812" name="DepConEmail1"
						value=<%=DepConEmail1%> class="form-control"
						id="InputDepConEmail1" required>
					<%
					}
					%>
				</div>
				<div class="form-group col-md-2">
					<label for="InputDepConEmail2">域名</label> 
					<select name="DepConEmail2" id="InputDepConEmail2" class="form-control">				
						<option selected><%=DepConEmail2==null?"选择域名":DepConEmail2 %></option>
						<option value="@163.com">@163.com</option>
						<option value="@swufe.edu.cn">@swufe.edu.cn</option>
						<option value="@qq.com">@qq.com</option>	  
					</select>
				</div>
			</div>
			<div class="form-row">		
				<div class="form-group col-md-6">
					<button name="btn" type="submit" class="btn btn-primary" value="添加">添加</button>
					<button name="btn" type="submit" class="btn btn-primary" value="返回">返回</button>
				</div>
			</div>
			<%if(submitFB=="提交成功"){
				System.out.println("提交成功！");
			}else if(submitFB=="提交失败"){
				System.out.println("提交失败！");
			}
				%>	
		</form>
	</div>

</body>
</html>